//
//  LNavigationViewController.m
//  PetExchange
//
//  Created by a on 2022/9/26.
//

#import "LNavigationViewController.h"

@interface LNavigationViewController ()

@end

@implementation LNavigationViewController

+ (void)initialize {
    // 顶部状态栏白色
//    [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
    // 设置所有的NavigationBar的title字体属性
//    [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName: MY_SCALE_BoldFont(18), NSForegroundColorAttributeName : MyColor(@"333333")}];
}

//设置状态栏背景颜色
- (void)setStatusBarBackgroundColor:(UIColor *)color {
    
    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
        statusBar.backgroundColor = color;
    }
    
}

-(UIStatusBarStyle)preferredStatusBarStyle
{
    
    return UIStatusBarStyleDefault;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBar.barTintColor = UIColor.blackColor;
    self.navigationBar.translucent = NO;
//    [self setStatusBarBackgroundColor:[UIColor whiteColor]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    
    if (self.viewControllers.count > 0) {
        if (self.viewControllers.count == 1) {
                   viewController.hidesBottomBarWhenPushed = YES;
        }
    } else {
        // 设置透明颜色才一致
        self.navigationBar.translucent = NO;
        [self setLeftBarItem:viewController];
        viewController.hidesBottomBarWhenPushed = NO;
    }
    [super pushViewController:viewController animated:YES];
}

- (void)setLeftBarItem:(UIViewController *)viewController {
//    if (![viewController isMemberOfClass:[LBaseViewController class]]) {
//        return;
//    }
//    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"img_back"] style:UIBarButtonItemStylePlain target:viewController action:@selector(popAction)];
//    viewController.navigationItem.leftBarButtonItem = leftItem;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
